//Jonathan Flessner
//27-April-2014
//getCost unit tests
//getCost should return cost
//or -1 if invalid card

#include <stdio.h>
#include <stdlib.h>
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"

#define TESTS_RUN 10000

void checkCost(int card, int cost){
	if(getCost(card) != cost){
		printf("FAIL: for card: %d, expected cost: %d, given cost: %d\n", card, cost, getCost(card));
	}
	return;
}

//returns expected cost of card
//returns -1 if bad card
int retCost(int card){
	if(card == 0)
		return 0;
	else if(card == 1)
		return 2;
	else if(card == 2)
		return 5;
	else if(card == 3)
		return 8;
	else if(card == 4)
		return 0;
	else if(card == 5)
		return 3;
	else if(card == 6)
		return 6;
	else if(card == 7)
		return 6;
	else if(card == 8)
		return 5;
	else if(card == 9)
		return 4;
	else if(card == 10)
		return 4;
	else if(card == 11)
		return 5;
	else if(card == 12)
		return 4;
	else if(card == 13)
		return 4;
	else if(card == 14)
		return 3;
	else if(card == 15)
		return 4;
	else if(card == 16)
		return 3;
	else if(card == 17)
		return 5;
	else if(card == 18)
		return 3;
	else if(card == 19)
		return 5;
	else if(card == 20)
		return 3;
	else if(card == 21)
		return 4;
	else if(card == 22)
		return 2;
	else if(card == 23)
		return 5;
	else if(card == 24)
		return 4;
	else if(card == 25)
		return 4;
	else if(card == 26)
		return 4;
	else
		return -1;
}

int main(){
	srand(2);							//random seed, not time to reproduce errors
	int card;							//to hold card number
	int expCost;						//to hold expected cost
	int i;								//loop iterator
	for(i = 0; i <= TESTS_RUN; i++){
		card = rand() % 28; 			//to give from 0-27. Note 27 should return -1 as it is invalid.
		expCost = retCost(card);		//unit test function to return expected cost
		checkCost(card, expCost);
	}
	printf("Tests completed: %d. Failed tests printed information.\n", TESTS_RUN);
	return 0;
}